package ssm.dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import ssm.dao.CategoryDao;
import ssm.pojo.Category;
import util.Dbutil;

import java.sql.SQLException;
import java.util.List;

public class CategoryDaoImpl implements CategoryDao {
    /**
     * 查询所有类别
     * @return
     * @throws SQLException
     */
    public List<Category> findAllCate() throws SQLException {
        QueryRunner qr = new QueryRunner(Dbutil.getDataSource());
        String sql = "select * from Category";
        List<Category> list = qr.query(sql, new BeanListHandler<Category>(Category.class));
        return list;
    }
}
